package com.example.demo.serviceimpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.demo.entity.BookComment;
import com.example.demo.mapper.BookCommentMapper;
import com.example.demo.service.BookCommentService;

/**
 * 评论的实现类
 * 
 * @author wang
 *
 */
@Service
public class BookCommentServiceImpl implements BookCommentService {

	@Autowired
	private BookCommentMapper bookCommentMapper;

	/**
	 * 查找相关书籍
	 */

	@Override
	public List<BookComment> FindBookId(Integer book_core_id) {
		return bookCommentMapper.FindBookId(book_core_id);
	}

	/**
	 * 根据book_core_id书籍的
	 */
	@Override
	public int findBookCoreId(Integer book_core_id) {
		return bookCommentMapper.findBookCoreId(book_core_id);
	}

	/**
	 * 根据和书id给书添加评论
	 * 
	 */
	@Override
	public int insertCommentId(BookComment bookComment) {
		return bookCommentMapper.insertCommentId(bookComment);
	}

	/**
	 * 根据评论Id查找评论
	 */
	@Override
	public BookComment findCommentIdAndInfo(Integer bookCommentId) {
		return bookCommentMapper.findCommentIdAndInfo(bookCommentId);
	}

	/**
	 * 根据书的id，type计算书评分的平均数
	 */
	@Override
	public float findTheAverage(Integer id) {
		return bookCommentMapper.findTheAverage(id);
	}

	/**
	 * 根据书id和用户id查找评论
	 */
	@Override
	public List<BookComment> findUseridAndBookid(Integer bookId) {
		return bookCommentMapper.findUseridAndBookid(bookId);
	}

	/**
	 * 根据评论id查找回复
	 */
	@Override
	public List<BookComment> findComentId(Integer commentId) {
		return bookCommentMapper.findComentId(commentId);
	}

	/**
	 * 根据评论id查找该记录是否为评论
	 * 
	 */
	@Override
	public BookComment findBookCommentOne(Integer id) {
		return bookCommentMapper.findBookCommentOne(id);
	}

	/**
	 * 根据评分，计算人数
	 */
	@Override
	public float findCountUserId(Integer grade, Integer grade1, Integer id) {
		return bookCommentMapper.findCountUserId(grade, grade1, id);
	}

	@Override
	public int findAccountUserIdNumber(Integer id) {
		return bookCommentMapper.findAccountUserIdNumber(id);
	}

	// /**
	// * 查询评论回复（书的id，type！=0）
	// */
	// @Override
	// public List<BookComment> findComentBookId(Integer book_core_id) {
	// // TODO Auto-generated method stub
	// return bookCommentMapper.findComentBookId(book_core_id);
	// }

	// @Override
	// public int updateReguseId(Integer id) {
	// // TODO Auto-generated method stub
	// return bookCommentMapper.updateReguseId(id);
	// }

}
